﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DataLayer
{
    public class VehiclesDL:BaseDL
    {
        /// <summary>
        /// Adds the selected vehicle for the user
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="vehicleId"></param>
        public void addUserVehicles(string userName, int vehicleId)
        {
            this._storedProcedureName = "addUserVehicles";
            this._params = new SqlParameter[] { 
                                                new SqlParameter("@Username",userName),
                                                new SqlParameter("@VehicleID",vehicleId)
                                              };

            this.executeProcedure();

        }
        /// <summary>
        /// Adds the selected vehicle for the user
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="vehicleId"></param>
        public void updateUserVehicleName(int userVehicleId, string name)
        {
            this._storedProcedureName = "updateUserVehicleName";
            this._params = new SqlParameter[] { 
                                                new SqlParameter("@UserVehicleID",userVehicleId),
                                                new SqlParameter("@Name",name)
                                              };

            this.executeProcedure();

        }
        /// <summary>
        /// Deletes a user vehicle
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="vehicleId"></param>
        public void deleteUserVehicle(string username, int vehicleId)
        {
            this._storedProcedureName = "deleteUserVehicle";
            this._params = new SqlParameter[] { 
                                                new SqlParameter("@Username",username),
                                                new SqlParameter("@VehicleID",vehicleId)
                                              };

            this.executeProcedure();
        }
        /// <summary>
        /// Gets all vehicles registered for the user
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public DataSet getUserVehicles(string username)
        {
            this._storedProcedureName = "getUserVehicles";
            this._params = new SqlParameter[] { 
                                                new SqlParameter("@Username",username)
                                                
                                              };

            return this.getDataSet();
        }
        /// <summary>
        /// Gets specific vehicle for the user
        /// </summary>
        /// <returns></returns>
        public DataSet getUserVehicleByVehicleId(string username, int vehicleId)
        {
            this._storedProcedureName = "getUserVehiclesBtVehicleId";
            this._params = new SqlParameter[] { 
                                                new SqlParameter("@Username",username),
                                                new SqlParameter("@VehicleId",vehicleId)
                                                
                                              };
            return this.getDataSet();
        }
        /// <summary>
        /// Gets all the vehicles in the system
        /// </summary>
        /// <returns></returns>
        public DataSet getVehicles()
        {
            this._storedProcedureName = "getVehicles";
            return this.getDataSet();
        }
    }
}
